<?php
@session_start();
 require_once("image.php"); ?>
<div class="panel panel-danger">
  <div class="panel-heading">
    <h3 class="panel-title">ยินดีต้อนรับ  <?php echo $_SESSION["account_name"];?></h3>
  </div>
  <div class="panel-body">
		<div>
			<center>
			<img src="<?php echo "../uploads/".$_SESSION["role"]."/pics/".$img;?>" style="width:60%;-webkit-box-shadow: 7px 5px 5px 0px rgba(153,151,153,1);
-moz-box-shadow: 7px 5px 5px 0px rgba(153,151,153,1);
box-shadow: 7px 5px 5px 0px rgba(153,151,153,1);" />
			</center>
		</div>
		<div style="padding:10px 0px 0px 10px;">
		
		<div style="padding:0px 0px 10px 10px;">
		<?php 
		if($_SESSION["role"]!="admin"){
		echo '<p><button class="btn btn-default popup_side_window" style="width:172px;text-align:left;"><span><img src="../pic/info.png" width="30" /> ข้อมูลส่วนตัว </span></button></p>';
		echo '<p><button class="btn btn-warning edit-profile" style="width:172px;text-align:left;"><span><img src="../pic/edit.png" width="30" /> แก้ไขข้อมูลส่วนตัว </span></button></p>';
		}
		?>
		</div>
			<div style="padding:0px 0px 10px 10px;">
		<p>
		<button type="button" class="btn btn-danger" style="width:172px;text-align:left;" onClick="if(window.confirm('ยืนยันการออกจากระบบ')) window.location='logout.php';">
		<span><img src="../pic/logout.png" width="30" />ออกจากระบบ</span></button>
		
		</p>
		</div>
		</div>
		
	
  </div>
</div>
<?php 
if($_SESSION["role"]!="admin"){
if($_SESSION["role"]=="students")$label_role="ข้อมูลผู้เรียน";else $label_role="ข้อมูลผู้สอน";
?>
<div id="data-info-popup" class="popup">
    <div class="popup-body"><span class="popup-exit"></span>
 
        <div class="popup-content">
            <h2 class="popup-title"><?php echo $label_role?></h2>
			<div class="popup-des">
			<img class="pics" src="../pic/bx_loader.gif" width="50" />
			</div>
        </div>
    </div>
</div>
<div class="popup-overlay"></div>
<script>
$(function(){
$('.popup_side_window').click(function () {
        $('html').addClass('overlay');
        var activePopup = "#data-info-popup";
        $(activePopup).addClass('visible');
		 $('.popup-overlay').click(function () {
        clearSidePopup();
		});
		$.ajax({
		url:"admin/preview_data.php?type=<?php if($_SESSION["role"]=="students")echo 1;else echo 2;?>&temp=<?php echo $_SESSION["id"] ?>",
			success:function(res){
			$(".popup-des").html(res);
			 $('.popup-exit').click(function () {
				clearSidePopup();
				});
			}
		});
 
    });
 
    $(document).keyup(function (e) {
        if (e.keyCode == 27 && $('html').hasClass('overlay')) {
            clearSidePopup();
        }
    });
	
	$(".edit-profile").click(function(){
	$('#h3title').html('แก้ไขข้อมุลส่วนตัว');
	$('#mainscreen').load('<?php if($_SESSION["role"]=="students")echo "student";else echo "teacher";?>/insert_<?php if($_SESSION["role"]=="students")echo "student";else echo "teacher";?>_page.php?temp=<?php echo $_SESSION["id"]?>');
	});
});
function clearSidePopup() {
        $('.popup.visible').addClass('transitioning').removeClass('visible');
        $('html').removeClass('overlay');
 
        setTimeout(function () {
            $('.popup').removeClass('transitioning');
        }, 200);
    }

</script>
<?php }?>


